#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
const int N = 1e5+10;
int vv[N],dd[N],aa[N],p[N],vis[N],t,n,m,l,v,sum;

void solve()
{
    for(int i = 1;i <= m;i++)
    {
        for(int j = 1;j <= n;j++)
        {
            int vj;
            vj = vv[j]*vv[j]+2*aa[j]*p[i];
            if(vj > v*v && vis[j] == 0)
            {
                sum++;
                vis[j]++;
            }
        }
    }
}

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    IOS;
    cin>>t;
    while(t--)
    {
        cin>>n>>m>>l>>v;
        for(int i = 1;i <= n;i++)
        {
            cin>>dd[i]>>vv[i]>>aa[i];
        }
        for(int i = 1;i <= m;i++)   cin>>p[i];
        solve();
        cout<<sum<<" "<<3;
    }
    return 0;
}

